from pyecharts.charts import Bar, Page, Line
from pyecharts import options as opts
import pandas as pd
import numpy as np

data = pd.read_csv('./results/中国油价/pred_results.csv')
x = []
for i in range(2000, 2032):
    x = x + [str(i)]
y1 = list(data['中国油价'])
for i in range(32):
    y1[i] = round(y1[i], 2)


def line_charts():
    c = Line()
    # 设置x轴
    c.add_xaxis(xaxis_data=x)
    # 设置y轴

    c.add_yaxis(series_name='中国油价', y_axis=y1)
    # c.add_yaxis(series_name='WTI原油期货价格', y_axis=y2)
    # 数据项设置
    c.set_global_opts(
        title_opts=opts.TitleOpts(title='中国油价走势'),
        legend_opts=opts.LegendOpts(is_show=True),
        tooltip_opts=opts.TooltipOpts(trigger='axis', axis_pointer_type='cross')
    )
    return c


# 绘制图表
c = line_charts()
c.render(path='line.html')
